import Request from '@/utils/request'

export function articleList(params) {
    return Request.get(
        'article/list',
        params
    )
}

export function articleHotList(params) {
    return Request.get(
        'article/hot/list',
        params
    )
}

export function articleAdminList(params) {
    return Request.get(
        'article/admin/list',
        params
    )
}

export function articleAdminDetail(articleId) {
    return Request.get(
        `article/admin/list/${articleId}`
    )
}

export function articleDetail(articleId) {
    return Request.get(
        `article/list/${articleId}`
    )
}

export function articleAdd(params) {
    return Request.post(
        'article/add',
        params
    )
}

export function articleEdit(article_id,params) {
    return Request.put(
        `article/edit/${article_id}`,
        params
    )
}

export function articleDelete(article_id) {
    return Request.delete(
        `article/edit/${article_id}`
    )
}

export function tagList(params) {
    return Request.get(
        'article/tag/list',
        params
    )
}

export function tagDelete(tag_id) {
    return Request.delete(
        `article/tag/edit/${tag_id}`
    )
}

export function tagAdd(params) {
    return Request.post(
        'article/tag/add',
        params
    )
}

export function tagEdit(tag_id,params) {
    return Request.put(
        `article/tag/edit/${tag_id}`,
        params
    )
}

export function tagColor(tag_id,params) {
    return Request.put(
        `article/tag/color/${tag_id}`,
        params
    )
}

export function adminTagList(params) {
    return Request.get(
        'article/tag/num',
        params
    )
}

export function fileUpload(file) {
    let formData = new FormData();
    formData.append("file_data", file);
    return Request.post(
        'article/file/upload',
        formData
    )
}


export function commentList(params) {
    return Request.get(
        'article/comment/list',
        params
    )
}

export function commentAdminList(params) {
    return Request.get(
        'article/admin/comment/list',
        params
    )
}

export function commentDelete(comment_id) {
    return Request.delete(
        `article/comment/edit/${comment_id}`,
    )
}

export function commentAdd(params) {
    return Request.post(
        'article/comment/add',
        params
    )
}
